package com.heavenick.app.jmx;

import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;

/**
 * 
 * @author HaiJun
 * @date 2013-2-4
 */
public class Hello extends NotificationBroadcasterSupport implements HelloMBean {
	
	private String name;
	private String birthday;
	private String opearate;
	
	public Hello(){
		name = "morenname";
		birthday = "1970-90-90";
		opearate = "moren opearate";
	}
	public Hello(String name,String birthday,String opearate){
		this.name = name;
		this.birthday = birthday;
		this.opearate = opearate;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
		Notification notification   = new Notification("jmxbook.ch2.helloWorld.test", 
				 this, -1,System.currentTimeMillis(), name );
		sendNotification( notification );      
	}

	public void printHello() {
		System.out.println(" name " + this.name+" age " +getage() +" say hello ! by "+opearate);
	}

	public void printHello(String whoName) {
		System.out.println(whoName +" say hello !");
	}

	public void setbirthday(String birthday) {
		// TODO Auto-generated method stub
		this.birthday = birthday;
	}

	public String getbirthday() {
		return birthday;
	}

	public String getage() {
		int birthyear = Integer.parseInt(birthday.substring(0, 4));
		return String.valueOf(2013-birthyear);
	}

	public void set(String name, String birthday, String opearate) {
		this.name = name;
		this.birthday = birthday;
		this.opearate=opearate;
	}

	public void setopearate(String opearate) {
		this.opearate = opearate;
	}

}
